package demo;

import java.lang.ref.WeakReference;
import java.lang.reflect.Field;
import java.lang.reflect.Method;



public class MainTest {
  public static void main(String[] args) throws ClassNotFoundException, InstantiationException, IllegalAccessException {
//    Class c = User.class;
//    User u = new User();
//    Class c = u.getClass();
//    Field[] file = c.getDeclaredFields();
//    for (Field f : file) {
//      System.out.println(f);
//    }
//    System.out.println("------------------------");
//    Method[] methods = c.getDeclaredMethods();
//    for (Method m : methods) {
//      System.out.println(m);
//    }
    
    Class c = Class.forName("demo.User");
    User user = (User) c.newInstance();
    System.out.println(user.hashCode());
    User user2 = (User) c.newInstance();
    System.out.println(user2.hashCode());
    
    System.out.println(System.getSecurityManager());
    
    User u1 = new User();
    WeakReference<User> weakUser = new WeakReference<User>(u1);
    User newUser = weakUser.get();
    System.out.println(newUser);
  }
}
